import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Demo {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource) dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/wangjunyi?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource) dataSource).setUser("root");
        ((MysqlDataSource) dataSource).setPassword("111111");

        Connection connection = dataSource.getConnection();

        //String sql = "insert into teacher values('赵六',30,180.6,80.0,'男','大专','2000-04-12 12:00:00',23451)";
        String sql = "delete from teacher where name = '赵六'";
        PreparedStatement statement = connection.prepareStatement(sql);
        int n = statement.executeUpdate();
        System.out.println("n = "+n);

        statement.close();
        connection.close();


    }
}
